# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=unicode-character-database
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=13.0.0
pkgrel=1
pkgdesc="Unicode Character Database (mingw-w64)"
arch=(any)
license=(BSD)
url="https://www.unicode.org/"
source=("UCD-${pkgver}.zip::https://www.unicode.org/Public/zipped/${pkgver}/UCD.zip"
        "Unihan-${pkgver}.zip::https://www.unicode.org/Public/zipped/${pkgver}/Unihan.zip"
        LICENSE)
noextract=({UCD,Unihan}-$pkgver.zip)
sha512sums=('aed6d06c370dd87bc5713e19ff4cde47b065b76a18149194fa843e4efc5269f749ec8905cad9132d3b803ab621a46e372052b8f3c3e9b6a65afa6516b0f2b4f2'
            '87238202b5da069ab1bbc4672d86c6fd0711e354fb17f53b0b4152850c56c0fa09e6e45820ae52d49756b25fe696518ceaa34cbfe5366ff60688c9a5c3a2d5be'
            '9ba78d68ed39745e55538180f132ff47423edb46adde7ac3e62a489870d153808bcf2db57b77e6a7cdae9b4fa03aba99cf228315b9a15be090bedef00b9e69ed')

package() {
  for _f in UCD Unihan; do
    install -Dm644 ${_f}-${pkgver}.zip "${pkgdir}${MINGW_PREFIX}/share/unicode/${_f}.zip"
    bsdtar -C "${pkgdir}${MINGW_PREFIX}/share/unicode" -x --no-same-owner --no-same-permissions -f $_f-$pkgver.zip
  done

  #  ln -s unicode "$pkgdir${MINGW_PREFIX}/share/${_realname}"
  # FS#49938: A bunch of compatibility symlinks
  mkdir -p ${pkgdir}${MINGW_PREFIX}/share/unicode/ucd
  cp -r * "${pkgdir}${MINGW_PREFIX}/share/unicode/ucd/"
  for _f in ${_realname} unicode-data unidata; do
    cp -r ${pkgdir}${MINGW_PREFIX}/share/unicode "${pkgdir}${MINGW_PREFIX}/share/${_f}/"
  done

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
